from sqlalchemy import Column, Integer, String, Boolean
from .base import Base

class User(Base):
    __tablename__ = "users"
    id = Column(Integer, primary_key=True, index=True)
    username = Column(String, unique=True, index=True)
    password = Column(String)
    is_active = Column(Boolean, default=True)
    # 用户属性
    department = Column(String)
    security_level = Column(Integer)

class Resource(Base):
    __tablename__ = "resources"
    id = Column(Integer, primary_key=True, index=True)
    name = Column(String, index=True)
    # 资源属性
    resource_type = Column(String)
    sensitivity = Column(Integer)

class Policy(Base):
    __tablename__ = "policies"
    id = Column(Integer, primary_key=True, index=True)
    # 策略规则，使用 SpEL 表达式
    rule = Column(String)
    # 策略适用的资源类型
    resource_type = Column(String)
    # 策略适用的操作
    operation = Column(String)